package MapBase.logic.decorate.tile
{
	import flash.display.Sprite;
	
	public class NormalTile
	{
		private var _obj:Sprite;	
		
		public var color:uint = 0x00FF00;
		
		public var width : Number;
		public var height : Number;
		public var type : int;
		
		public function NormalTile(obj:Sprite,width:Number,height:Number,type:int)
		{
			_obj = obj;
			
			this.width = width;
			this.height = height;
			this.type = type;
			
			draw();
		}
		
		public function invalidate():void
		{
			draw();
		}
		
		public function draw():void
		{
			var tileW : int = width;
			var tileH : int = height;
			
			_obj.graphics.clear();
			_obj.graphics.lineStyle(1,0x000000);
			_obj.graphics.beginFill(color);
			
			if(type == 1)
			{
				_obj.graphics.moveTo(0,0);
				_obj.graphics.lineTo(-tileW/2,tileH/2);
				_obj.graphics.lineTo(0,tileH);
				_obj.graphics.lineTo(tileW/2,tileH/2);
				_obj.graphics.lineTo(0,0);
			}
			else if(type == 2)
			{
				_obj.graphics.moveTo(0,0);
				_obj.graphics.lineTo(-tileW/2,tileH/2);
				_obj.graphics.lineTo(0,tileH);
				_obj.graphics.lineTo(tileW/2,tileH/2);
				_obj.graphics.lineTo(0,0);
			}
			else if(type == 3)
			{
//				_obj.graphics.moveTo(0,0);
//				_obj.graphics.lineTo(0,tileH);
//				_obj.graphics.lineTo(tileH,tileH);
//				_obj.graphics.lineTo(tileH,0);
//				_obj.graphics.lineTo(0,0);
				_obj.graphics.moveTo(0,0);
				_obj.graphics.lineTo(-tileW/2,tileH/2);
				_obj.graphics.lineTo(0,tileH);
				_obj.graphics.lineTo(tileW/2,tileH/2);
				_obj.graphics.lineTo(0,0);	
			}
			
			_obj.graphics.endFill(); 
		}
	}
}